import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)
const VueRouterPush = Router.prototype.push;
Router.prototype.push = function push(to) {
    return VueRouterPush.call(this, to).catch(err => err)
};

// 路由表
export const routes = [{
        path: '/login',
        name: 'login',
        component: () =>
            import ('@/views/login/index')
    },
    {
        path: '/',
        redirect: '/home',
        name: 'layout',
        component: () =>
            import ('@/views/layout/layout'),
        children: [{
                path: 'home', // 默认子路由
                name: 'home',
                component: () =>
                    import ('@/views/home/index')
            },
            {
                path: 'qa',
                name: 'qa',
                component: () =>
                    import ('@/views/qa/index')
            },
            {
                path: '/video',
                name: 'video',
                component: () =>
                    import ('@/views/video/index')
            },
            {
                path: '/my',
                name: 'my',
                component: () =>
                    import ('@/views/my/index')
            }
        ]
    }
]

const router = new Router({
    routes
})

export default router